home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / myvcs / myvcs.txt < prev    next >
Text File  |  1996-04-08  |  4KB  |  89 lines

  1.  
  2. MYVCS - Pete Cervasio's Non-Version Control System.  Version 1.0
  3.  
  4. A really stupid example of how to interface with the Version Control Manager
  5. in Borland's Delphi.
  6.  
  7. Copyright 1995, Peter W. Cervasio
  8. All Rights Undeserved.
  9.  
  10. This is really stupid, but it shows how to use the VCSINTF and TOOLINTF
  11. units.  I don't really have any plans on expanding this into a real version
  12. control system.  Maybe someone out there will do it.  If you do, please
  13. remember where you learned this, and send me a registered copy of it.  I
  14. could really use one.  <grin>
  15.  
  16. How did I figure this out??  Well, I looked at the demo source code for the
  17. App/Dialog Expert.  That showed me a lot about how the TOOLINTF unit was
  18. used.  I then slowly but surely added more and more functions into this
  19. little DLL until it looked like it showed enough.
  20.  
  21. This code is released as freely available software.  You may do anything you
  22. wish to with it, including making the the worlds greatest version control
  23. system and selling it for a lot of money.  I don't care, I just wanted to
  24. figure out what I could about the VCS Manager.  The only thing you can't do
  25. is pretend that you wrote this.  Ugh... who would want to admit that,
  26. anyway?  I don't even want to, but my user-id is going to be on the upload
  27. description, so I might as well admit it.  <big grin>
  28.  
  29. One exception to the preceeding paragraph: Borland International is granted
  30. any rights to this code that they want.  I especially hope that that they
  31. will take this code, do whatever cleanup they feel needs done, and include
  32. it in the next release of Delphi so people will understand what's going on
  33. with the VCSINTF unit a bit.
  34.  
  35. The real work goes on in MYVCS.PAS.  The code that starts the conversation
  36. between Delphi and MyVCS is in the function MyVCSInit.  Here it is:
  37.  
  38.     function MyVCSInit (VCSInterface: TIToolServices): TIVCSClient; export;
  39.     begin
  40.         ToolInterface := VCSInterface;
  41.         if ToolInterface <> nil then
  42.         begin
  43.             MyVCSClient := TMyVCSClient.Create;
  44.             WindowHandle := VCSInterface.GetParentHandle;
  45.             result := MyVCSClient;
  46.         end
  47.         else
  48.             result := nil;
  49.     end;
  50.  
  51. I've declared ToolInterface as a global TIToolServices, and MyVCSClient as a
  52. global TMyVCSClient.  If I receive a valid VCSInterface from Delphi, I
  53. assign it to ToolInterface, and create a TMyVCSClient to pass back.  If not,
  54. I return nil.  When things weren't working so well (the first couple of
  55. tries), I would get a "Could not open communication with the VCS Manager"
  56. type of message from Delphi, but everything else kept working so I guess
  57. this is the right thing to do.
  58.  
  59. All the rest of the work happens in the TMyVCSClient class.  As a menu title
  60. to add to the Delphi menubar, I'm returning "&Workgroup".  This is what the
  61. PVCS interface uses, so I guess it's a pretty good 'standard' to use.  The
  62. number of menu items is returned by the GetVerbCount method, and the text of
  63. those items is returned by the GetVerb(Index) method.  The state of the menu
  64. items is set with GetVerbState(Index).  Since this is a really stupid
  65. example, I'm just returning vsEnabled for any menu item.  In a *real* VCS
  66. manager, you would enable and disable options as the project state changes.
  67.  
  68. When the user picks one of those menu items, the ExecuteVerb method is
  69. called with the index of the menu item selected.  This is fairly straight-
  70. forward.  The ToolServices object we were passed on initialization allows us
  71. to open files, close files, get a list of units and forms, and all kinds of
  72. things.  The only things this DLL does: open a file, close the current
  73. project or file (which might be a form or a unit), show a list of units and
  74. forms in the project, and two goofy little dialog boxes that show the number
  75. of files and units.  These last two are leftovers from the very first
  76. incarnation of the DLL.  Oh, there's an about box, too.
  77.  
  78. I hope this helps people understand how the VCS Interface unit works, and
  79. how you would go about sticking a version control system into Delphi. Again,
  80. it's a really stupid example, but it works.  :-)
  81.  
  82. If you want to contact me about this code, I can be reached either in the
  83. Delphi forum on Compuserve, or via Fidonet netmail.  I can't promise to
  84. answer your questions, but I'll try.
  85.  
  86. Peter Cervasio
  87. Compuserve:  73443,1426     Fidonet: 1:130/209
  88.  
  89.